<script setup>
import { onMounted, ref, defineProps, defineEmits } from 'vue'
import { getArticleCatagoryAPI } from '@/api/article.js'

// 文章分类数据
const articleCatagory = ref([])

// 获取文章分类
const getArticleCatagory = async () => {
  const res = await getArticleCatagoryAPI()
  articleCatagory.value = res.data.data
}
// 初始化调用
onMounted(() => {
  getArticleCatagory()
})

// 获取父组件传递的值
const props = defineProps({
  modelValue: {
    type: [Number, String]
  }
})
const emit = defineEmits(['update:modelValue'])
</script>
<template>
  <el-select
    :modelValue="props.modelValue"
    @update:modelValue="emit('update:modelValue', $event)"
  >
    <el-option
      v-for="item in articleCatagory"
      :key="item.id"
      :label="item.cate_name"
      :value="item.id"
    ></el-option>
  </el-select>
</template>

<style lang="scss" scoped></style>
